package org.ywf.web.controller;

import com.ywf.Boy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.ywf.common.R;
import org.ywf.common.entity.RequestData;
import org.ywf.common.entity.ResponseData;
import org.ywf.common.request.NewsReq;
import org.ywf.web.entity.User;
import org.ywf.web.entity.WelgowReq;
import org.ywf.web.service.UserService;

import javax.annotation.Resource;
import java.io.File;
import java.util.List;

@RestController
public class UserController {
    @Resource
    private UserService userService;

    @PostMapping(value = "/getUserinfo")
    public R getUserinfo(@RequestBody RequestData<NewsReq> request){
        ResponseData<List> responseData = userService.printTest(request);
        return R.ok().data(responseData);
    }

    @PostMapping(value = "/getJoinList")
    public R getJoinList(@RequestBody User user){
        ResponseData<List> responseData = userService.getJoinList(user);
        return R.ok().data(responseData);
    }

    @Resource
    private Boy boy;



    @GetMapping(value = "/getHostInfo")
    public R getHostInfo(){
        userService.getHostInfo();
        String fsdf = boy.say();
        System.out.println("sdfsd:"+fsdf);
        return R.ok();
    }

    @GetMapping(value = "/sftpDownload")
    public R sftpService(){
        List<File> response = userService.sftpDownload();
        return R.ok().data(response);
    }

    @GetMapping(value = "/sftpUpload")
    public R sftpUpload(@RequestParam("filePath") String filePath){
        Boolean response = userService.sftpUpload(filePath);
        if (response){
            return R.ok().data(response);
        }
        return R.error();
    }
    




    @PostMapping(value = "/getJoinList")
    public R getWelgow(@RequestBody WelgowReq welgowReq){
        ResponseData<List> responseData = userService.getWelgow(welgowReq);
        return R.ok().data(responseData);
    }

}
